//
//  ZCinvolvedOtherCell.m
//  zctx
//
//  Created by apple on 15/12/28.
//  Copyright © 2015年 sanliang. All rights reserved.
//

#import "ZCinvolvedOtherCell.h"

@implementation ZCinvolvedOtherCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellType:(ZCinvolvedOtherCellType)type{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        if (type == ZCinvolvedOtherCellTypeicon) {
    
        } else if (type == ZCinvolvedOtherCellTypecontent) {
            [self addLabelContents];
        } else if (type == ZCinvolvedOtherCellTypestate) {
            [self addLabelTitle];
            [self addrightImgViews];
        }else if (type ==ZCinvolvedOtherCellTypedetails){
            self.contentView.backgroundColor = [UIColor colorWithHexString:@"#FEF8E2"];
            [self addLabelTitle];
            [self addrightImgViews];
            [self.rightImgView setImage:[UIImage imageNamed:@"involved_right"]];
            self.labelTitle.text = @"检测详情";
            self.labelTitle.textColor = [UIColor colorWithHexString:@"#03AB9E"];
        }else if (type == ZCinvolvedOtherCellTypetitle){
            self.selectionStyle = UITableViewCellSelectionStyleNone;
            [self addLabelTitle];
            [self addCommentButtons];
            [self addDiLines];
            [self.commentButton setTitle:@"+我来说两句" forState:UIControlStateNormal];
            [self.commentButton setTitleColor:[UIColor colorWithHexString:@"#03ab9e"] forState:UIControlStateNormal];
        }else if (type ==ZCinvolvedOtherCellTypeCenter){
            [self addLabelCenter];
        }
    }
    return self;
}

-(void)setModels:(ZCInvolvedDetailsModelContent *)models{
    _models = models;
    
    [self setNeedsUpdateConstraints];
    [self updateConstraintsIfNeeded];
}


- (void)addLabelTitle {
    [self.contentView addSubview:self.labelTitle];
    [self.labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.equalTo(self.contentView.height);
        make.left.mas_equalTo(@(15));
    }];
}
- (void)addLabelInfo {
    [self.contentView addSubview:self.labelInfo];
    [self.labelInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.equalTo(self.contentView.height);
        make.right.mas_equalTo(@(-15));
        make.left.equalTo(self.labelTitle.right).with.offset(10);
    }];
}

- (void)addLabelCenter {
    [self.contentView addSubview:self.lableCenter];
    [self.lableCenter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.mas_equalTo(21);
        make.right.equalTo(self.contentView.right).with.offset(-18);;
        make.left.equalTo(self.contentView.left).with.offset(18);
    }];
}

-(void)addrightImgViews{
    [self.contentView addSubview:self.rightImgView];
    [self.rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.mas_equalTo(13);
        make.right.equalTo(self.contentView.right).with.offset(-18);
        make.width.mas_equalTo(7);
    }];
}

-(void)addCommentButtons{
    [self.contentView addSubview:self.commentButton];
    [self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.mas_equalTo(25);
        make.right.equalTo(self.contentView.right).with.offset(-18);
        make.width.mas_equalTo(100);
    }];
}


- (void)addLabelContents {
    [self.contentView addSubview:self.labelcontent];
    [self.labelcontent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.centerY);
        make.height.equalTo(self.contentView.height);
        make.left.mas_equalTo(@(18));
        make.right.mas_equalTo(@(-18));
    }];
}


- (void)addDiLines {
    [self.contentView addSubview:self.diLine];
    [self.diLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self.contentView.left).with.offset(0);
        make.right.equalTo(self.contentView.right).with.offset(0);
        make.bottom.equalTo(self.contentView.bottom).with.offset(0);
    }];
}


#pragma mark - instance

- (UILabel *)labelTitle {
    if (!_labelTitle) {
        _labelTitle = [[UILabel alloc] init];
        _labelTitle.font = [UIFont systemFontOfSize:15];
        [_labelTitle setTextColor:[UIColor colorWithHexString:@"#666666"]];
    }
    return _labelTitle;
}

- (UILabel *)labelInfo {
    if (!_labelInfo) {
        _labelInfo = [[UILabel alloc] init];
        _labelInfo.font = [UIFont systemFontOfSize:15];
        _labelInfo.textAlignment = NSTextAlignmentLeft;
        [_labelInfo setTextColor:[UIColor colorWithHexString:@"000000"]];
    }
    return _labelInfo;
}

- (UILabel *)lableCenter {
    if (!_lableCenter) {
        _lableCenter = [[UILabel alloc] init];
        _lableCenter.font = [UIFont systemFontOfSize:15];
        _lableCenter.textAlignment = NSTextAlignmentCenter;
        [_lableCenter setTextColor:[UIColor colorWithHexString:@"#03ab9e"]];
    }
    return _lableCenter;
}

- (UIImageView *)rightImgView {
    if (!_rightImgView) {
        _rightImgView = [[UIImageView alloc] init];
        [_rightImgView setImage:[UIImage imageNamed:@"raise_right"]];
    }
    return _rightImgView;
}

- (UILabel *)labelcontent {
    if (!_labelcontent) {
        _labelcontent = [[UILabel alloc] init];
        _labelcontent.font = [UIFont systemFontOfSize:14];
        _labelcontent.numberOfLines = 0;
        _labelcontent.text = @"";
        [_labelcontent setTextColor:[UIColor colorWithHexString:@"000000"]];
    }
    return _labelcontent;
}

-(UIButton *)commentButton{
    if (!_commentButton) {
        _commentButton = [[UIButton alloc]init];
        _commentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        _commentButton.titleLabel.font = [UIFont systemFontOfSize:15];
        [_commentButton addTarget:self action:@selector(ClickCommentButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _commentButton;
}

-(UIView *)diLine{
    if (!_diLine) {
        _diLine = [[UIView alloc]init];
        _diLine.backgroundColor = RGB(236, 237, 238);
        
    }
    return _diLine;
}

#pragma mark 点击我想说两句
-(void)ClickCommentButton{
    NSLog(@"点击了我想说两句");
    if (_delegate && [ _delegate respondsToSelector:@selector(ClickCommentButtonconnect)]) {
        [_delegate ClickCommentButtonconnect];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
